<?php
include_once( dirname(__FILE__) . '/../../vendor/smarty/Smarty.class.php');

class BlogSmarty extends Smarty
{
	public function __construct()
	{
		parent::__construct();
		
		$this->setTemplateDir(dirname(__FILE__) . "/../../resources/templates/");
		$this->setCompileDir(dirname(__FILE__) . "/../../resources/templates_c/");
		
		global $driver;
		global $dbinfo;
		global $params;
		$tr =& Translation2::factory($driver, $dbinfo, $params);
		
		$languages = $tr->getlangs('array');
		$this->assign("languages", $languages);
		
		if(Authentication::getCurrentUser()->get_level() != User::GUEST) {
			$this->assign("links", array(
				array("url" => "/post/add/", "title" => "Post toevoegen"),
				array("url" => "/logout", "title" => "Logout")
			));
		}
		
		$smarty_articles = array();
		
		$articles = ArticlesQuery::create()->orderByDateCreated("desc")->setLimit(5)->find();
		foreach($articles as $article) {
			$smarty_articles[] = array("id" => $article->getId(), "title" => $article->getTitle());
		}
		
		$this->assign("archives", $smarty_articles);
	}
}
?>
